import { ref, onMounted, onUnmounted } from 'vue'
export default function() {
  // 独立的功能，返回滚动高度
  const top = ref(0)

  const update = () => {
    // const H = document.body && document.body.clientHeight
    // top.value = H - 250 + "px"
    top.value = window.scrollY
  }

  // 防抖生命周期
  onMounted(() => {
    window.addEventListener('scroll', update)
  })

  onUnmounted(() => {
    window.removeEventListener('scroll', update)
  })
  return { top }
}
